/**
 * amis-core v2.4.0
 * Copyright 2018-2022 fex
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
require('../utils/api.js');
require('../utils/ColorScale.js');
require('react');
require('lodash/chunk');
require('amis-formula');
require('lodash/isPlainObject');
require('../utils/DataSchema.js');
require('../utils/DataScope.js');
require('moment');
require('../utils/debug.js');
require('react-dom');
require('../utils/errors.js');
require('../utils/tpl.js');
var helper = require('../utils/helper.js');
require('classnames');
require('../utils/filter.js');
require('lodash/isObject');
require('lodash/isString');
require('lodash/isBoolean');
require('lodash');
require('../utils/image.js');
var Action = require('./Action.js');
require('../utils/resize-sensor.js');
require('../node_modules/dom-helpers/esm/addEventListener.js');
require('../utils/SimpleMap.js');
require('lodash/mapValues');
require('lodash/camelCase');
require('uncontrollable');
require('hoist-non-react-statics');
require('../utils/validations.js');
require('../utils/Animation.js');

/**
 * 自定义动作，JS脚本
 *
 * @export
 * @class CustomAction
 * @implements {ActionObject}
 */
var CustomAction = /** @class */ (function () {
    function CustomAction() {
    }
    CustomAction.prototype.run = function (action, renderer, event) {
        var _a, _b;
        return tslib.__awaiter(this, void 0, void 0, function () {
            var scriptFunc;
            return tslib.__generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        scriptFunc = (_b = (_a = action.args) === null || _a === void 0 ? void 0 : _a.script) !== null && _b !== void 0 ? _b : action.script;
                        if (typeof scriptFunc === 'string') {
                            scriptFunc = helper.promisify(new Function('context', 'doAction', 'event', scriptFunc));
                        }
                        return [4 /*yield*/, (scriptFunc === null || scriptFunc === void 0 ? void 0 : scriptFunc.call(null, renderer, function (action) { return Action.runActions(action, renderer, event); }, event, action))];
                    case 1:
                        _c.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    return CustomAction;
}());
Action.registerAction('custom', new CustomAction());

exports.CustomAction = CustomAction;
